New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

roi

Package Overview
Dependencies
Maintainers
4
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

roi

A dependency-free http module.

  • 0.16.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
61
decreased by-29.89%
Maintainers
4
Weekly downloads
 
Created
Source

roi

Coverage Status Build Status Known Vulnerabilities dependencies Status

NPM

A dependency-free http module.

Project Info
License:Apache-2.0
Build:make
Documentation:http://bucharest-gold.github.io/roi
Issue tracker:https://github.com/bucharest-gold/roi/issues
Engines:Node.js 4.x, 6.x, 8.x

Installation

npm install roi -S

Usage

const roi = require('roi');

const options = {endpoint: 'http://localhost:3000/posts'};

roi.get(options)
.then(response => {
  console.log(response);
  console.log(response.statusCode);
  console.log(response.headers);
  console.log(response.body);
})
.catch(e => console.log(e));

More examples

POST
const options = {endpoint: 'http://localhost:3000/posts'};

const foo = {
  title: 'foo-json',
  author: 'bgold'
};

roi.post(options, foo)
.then(response => console.log(response)
.catch(e => console.log(e));
PUT
const options = {endpoint: 'http://localhost:3000/posts/2'};

const foo = {
  title: 'foo-json2',
  author: 'bgold'
};

roi.put(options, foo)
.then(response => console.log(response))
.catch(e => console.log(e));
DELETE
const options = {endpoint: 'http://localhost:3000/posts/3'};

roi.del(options)
.then(response => console.log(response))
.catch(e => console.log(e));
HEAD
const options = {endpoint: 'http://localhost:3000/posts/3'};

roi.head(options)
.then(response => console.log(response.statusCode === 200))
.catch(e => console.log(e));
DOWNLOAD
const options = {endpoint: 'https://github.com/bucharest-gold/roi/raw/master/test/green.png'};
roi.download(options, '/tmp/green.png')
.then(x => console.log(x))
.catch(e => console.log(e));
UPLOAD
// Fake server side app will save the file called myFileUploaded.png :
const up = (request, response) => {
  request
    .pipe(fs.createWriteStream('/tmp/myFileUploaded.png'))
    .on('finish', () => {
      response.end(request.headers.filename);
    });
};
const server = require('http').createServer(up);
server.listen(3002, () => {});
// Upload and check if the uploaded file exists:
const options = {endpoint: 'http://localhost:3002/'};
roi.upload(options, '/tmp/myFile.png')
.then(response => {
  console.log(fs.existsSync('/tmp/myFileUploaded.png'));
});
Basic authentication
// Add the username and password:
const options = {
  endpoint: 'http://localhost:3000/',
  username: 'admin',
  password: 'admin'
};
roi.get(options)
.then(response => console.log(response))
.catch(e => console.log(e));

Contributing

Please read the contributing guide

Keywords

FAQs

Package last updated on 03 Oct 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc